import java.util.*;

public class Tongji {
    public static void main(String[] args){
        //1.需要先让同学们投票
        //定义一个数组，存储四个景点
        String[] arr={"A","B","C","D"};
        //利用随机数模拟80个同学的投票次数，存储投票结果
        ArrayList<String> list= new ArrayList<>();
        Random r=new Random();
        for (int i=0;i<80;i++){
            int index=r.nextInt(arr.length);
            list.add(arr[index]);

        }

        //2.不方便用计数器统计，用map集合统计
        HashMap<String,Integer> hm = new HashMap<>();
        for (String name:list){
            if (hm.containsKey(name)){
                int count=hm.get(name);
                count++;
                hm.put(name,count);

            }else
            {
                hm.put(name,1);
            }
        }
        System.out.println(hm);
     //3。求最大值
        int max=0;
        Set<Map.Entry<String, Integer>> entries = hm.entrySet();
        for (Map.Entry<String, Integer> entry : entries) {
            int count=entry.getValue();
            if (count>max){
                max=count;
            }
        }
        System.out.println(max);

        for (Map.Entry<String, Integer> entry : entries) {
            int count=entry.getValue();
            if (count==max){
                System.out.println(entry.getKey());
            }
        }
    }


}
